﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports GenDotNet.TemplateSupport.Strings

Public Class InterfaceItemInfo
   Inherits BaseInfo

   Private mInterfaceName As String
   Private mMemberName As String

   Public Sub New(ByVal interfaceName As String, ByVal memberName As String)
      MyBase.New(interfaceName & "|" & memberName, TemplateSupport.Scope.Unknown)
      mInterfaceName = interfaceName
      mMemberName = memberName
   End Sub

   Public ReadOnly Property InterfaceName() As String
      Get
         Return mInterfaceName
      End Get
   End Property

   Public ReadOnly Property MemberName() As String
      Get
         Return mMemberName
      End Get
   End Property
End Class

Public Class InterfaceItemInfoCollection
   Inherits List(Of InterfaceItemInfo)

   Public Overloads Sub Add(ByVal interfaceName As String, ByVal memberName As String)
      Me.Add(New InterfaceItemInfo(interfaceName, memberName))
   End Sub

End Class

Namespace VB
   Public Module InterfaceItemInfoExtensions

      <Runtime.CompilerServices.Extension()> _
      Public Function OutputDeclaration( _
               ByVal infos As InterfaceItemInfoCollection) _
               As String
         If infos Is Nothing OrElse infos.Count = 0 Then
            Return String.Empty
         End If
         Return _
<code> Implements <%= (From info In infos Select _
                     <code>
                        <%= info.InterfaceName %>.<%= info.MemberName %>
                     </code>).ConcatenateWithNewLine() %>
</code>.Value
      End Function

   End Module
End Namespace

Namespace CSharp
   Public Module InterfaceItemInfoExtensions
      <Runtime.CompilerServices.Extension()> _
      Public Function OutputDeclaration( _
               ByVal infos As InterfaceItemInfoCollection) _
               As String
         Throw New NotImplementedException("Interfaces are not yet designed for C#")
      End Function

   End Module
End Namespace
